import { defineStore } from 'pinia'

interface MusicState {
  localMusicDirs: string[] // 本地音乐目录列表
}

export const useMusicStore = defineStore('music', {
  state: (): MusicState => ({
    localMusicDirs: []
  }),
  
  actions: {
    // 添加本地音乐目录
    addLocalMusicDir(dir: string) {
      if (!this.localMusicDirs.includes(dir)) {
        this.localMusicDirs.push(dir)
      }
    },
    
    // 移除本地音乐目录
    removeLocalMusicDir(dir: string) {
      const index = this.localMusicDirs.indexOf(dir)
      if (index > -1) {
        this.localMusicDirs.splice(index, 1)
      }
    },

    // 设置本地音乐目录列表
    setLocalMusicDirs(dirs: string[]) {
      this.localMusicDirs = dirs
    }
  },

  persist: {
    enabled: true,
    strategies: [
      {
        storage: localStorage,
        paths: ['localMusicDirs']
      }
    ]
  }
}) 